"""
Case Type   : 行存压缩
Case Name   : 行存压缩后置处理
Create At   : 2024/11/25
Owner       : @li-xin12345
Description :
    1、恢复support_extended_features为off。
Expect      :
    1、成功
History     :
"""

import os
import unittest

from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger


class RowCompressTest(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.pri_sh = CommonSH('PrimaryDbUser')
        self.constant = Constant()

    def test_row_compress_teardown(self):
        text = '-----step1:恢复support_extended_features为off;expect:成功-----'
        self.log.info(text)
        res = self.pri_sh.execute_gsguc(
            'set', self.constant.GSGUC_SUCCESS_MSG,
            'support_extended_features=off')
        self.log.info(res)
        self.assertTrue(res, f'执行失败：{text}')
        restart_res = self.pri_sh.restart_db_cluster()
        self.log.info(restart_res)
        self.assertTrue(restart_res)
        status = self.pri_sh.get_db_cluster_status()
        self.assertTrue("Degraded" in status or "Normal" in status)

    def tearDown(self):
        self.log.info('-----teardown:无需其他清理步骤-----')
        self.log.info(f'-----{os.path.basename(__file__)} end-----')